package com.avery.mile.hadoop.rpc.hadoop;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import org.apache.log4j.BasicConfigurator;

import java.io.IOException;

/**
 * Created by avery on 2018/12/26.
 */
public class HadoopRpcServer {

    public static final String IP = "localhost";
    public static final int PORT = 8090;

    public static void main(String[] args) {
        BasicConfigurator.configure();
        final HadoopRpcProtoclImpl protocl = new HadoopRpcProtoclImpl();
        try {
            final RPC.Server server
                    = new RPC.Builder(new Configuration())
                            .setBindAddress(IP)
                            .setPort(PORT)
                            .setInstance(protocl)
                            .setProtocol(HadoopRpcProtocol.class)
                            .setVerbose(true)
                            .build();
            server.start();

        } catch (IOException e) {
        }
    }
}
